<template>
  <div class="modal-overlay" v-if="isVisible" @click="closeModal">
    <div class="modal-content" @click.stop>
      <div class="modal-head">
        <div></div>
        <div class="modal-top">
          <img :src="up" alt="" />
          <p class="title">上传我的音乐</p>
        </div>
        <div @click="closeModal">
          <el-icon><CircleClose /></el-icon>
        </div>
      </div>
      <div class="choices">
        <div
          :class="['item', choiceId == '上传Python代码' ? 'on' : '']"
          @click="choice('上传Python代码')"
        >
          <img :src="Python" alt="" />
          <p>上传Python代码</p>
        </div>
        <div
          :class="['item', choiceId == '上传音频' ? 'on' : '']"
          @click="choice('上传音频')"
        >
          <img :src="methodimg" alt="" />
          <p>上传音频</p>
        </div>
        <!-- <button @click="selectOption('Option 1')"></button>
        <button @click="selectOption('Option 2')"></button> -->
      </div>
      <div class="btn" @click="selectOption">
        <button>确定</button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from "vue";
import up from "@/assets/img/up.png";
import Python from "@/assets/img/98.png";
import methodimg from "@/assets/img/99.png";

const props = defineProps({
  isVisible: Boolean,
});
const emit = defineEmits(["update:isVisible", "option-selected"]);
const choiceId = ref(null);

const closeModal = () => {
  emit("update:isVisible", false);
};

const selectOption = () => {
  emit("option-selected", choiceId.value);
  closeModal();
};
const choice = (data) => {
  choiceId.value = data;
};
</script>

<style scoped lang="scss">
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5); /* 半透明背景 */
  display: flex;
  align-items: center;
  justify-content: center;
  .modal-content {
    width: 400px;
    //   height: 200px;
    background: linear-gradient(
      to bottom right,
      #ebfff3,
      #ffffff
    ); /* 渐变背景色 */
    // border-radius: 8px;
    padding: 20px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    color: black;
    text-align: center;
    .modal-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      .modal-top {
        display: flex;
        align-items: center;
        .title {
          height: 30px;
          line-height: 30px;
          font-size: 17px;
          font-weight: bold;
        }
        img {
          width: 25px;
          height: 25px;
        }
      }
    }
    .choices {
      margin-top: 20px;
      display: flex;
      justify-content: space-evenly;
      align-items: center;
      .item {
        width: 45%;
        height: 200px;
        background-color: white;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: space-evenly;
        border: 2px solid #eee;
        border-radius: 8px;
        img {
          width: 70px;
          height: 70px;
        }
        &.on {
          border: 2px solid #586f53;
        }
      }
      .item:hover {
        border: 2px solid #586f53;
      }
    }

    .btn {
      margin-top: 20px;
      button {
        background: #0dcc80;
        color: white;
        border: none;
        border-radius: 5px;
        padding: 7px 30px;
        margin: 5px;
        cursor: pointer;
        font-size: 16px;
      }
    }
  }
}
</style>
